﻿#region codejockey.net Copyright Banner

/***************************************************************\
 * Copyright 2010 codejockey.net.                                *
 *                                                               *
 * This code is property of codejockey.net and cannot be used    *
 * without explicit permission given by a codejockey.net         *
 * Representative.  For details contact: source@codejockey.net   *
 \***************************************************************/

#endregion

#region Using Clause

using codejockey.Shared.Text.ReplacementTokens;

#endregion

namespace codejockey.BingPaper.Utils.ReplacementTokens
{
  public class BingImageNameReplacementToken : ReplacementTokenBase
  {
    private const string TokenText = "$bingimagename$";
    private const string TokenName = "Bing Image Name Replacement Token";

    private const string TokenDescription =
      "The Bing Image Name Replacement Token provides for the current Bing image TokenName.";

    private readonly string _imageName;

    public BingImageNameReplacementToken(string bingImageName)
    {
      _imageName = bingImageName;
    }

    public override string GetName()
    {
      return TokenName;
    }

    public override string GetDescription()
    {
      return TokenDescription;
    }

    public override string GetToken()
    {
      return TokenText;
    }

    public override string Replace(string tokenizedString)
    {
      tokenizedString = base.Replace(tokenizedString);

      if (tokenizedString.Contains(TokenText))
      {
        tokenizedString = tokenizedString.Replace(GetToken(), _imageName);
        Processed = true;
      }

      return tokenizedString;
    }
  }
}